window.onload = function() {

	//获取首页banner数据
	request(base_url + '/game/member/banner/' + channel_code)
		.done(function(data) {
			dealHomeBanner(data);
		})
		.fail(function() {
			console.log('home banner error');
		});

	//	$.ajax({
	//				type: 'get',
	//				url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/banner/34998a46-7aca-46b9-b3aa-17ec7dac5275',
	//				json: true,
	//				contentType: 'application/json',
	//				success: function(data) {
	//					console.log(data);
	//					//			dealHomeBanner(data);
	//				},
	//				error: function(data) {
	//					console.log('home banner error,data:' + data);
	//				}
	//	});

	function dealHomeBanner(json) {
		for(var home_banner_num = 0; home_banner_num < json.items.length; home_banner_num++) {
			var home_banner_container = document.getElementsByClassName('swiper-container-home');
			var div = document.createElement('div');
			div.className = 'swiper-slide';
			var a = document.createElement('a');
			a.href = json.items[home_banner_num].jump_url;
			var img = document.createElement('img');
			img.src = json.items[home_banner_num].cover;
			a.appendChild(img);
			div.appendChild(a);
			home_banner_container[0].children[0].appendChild(div);
		}
	}

	//获取发现页banner数据
	request(base_url + '/game/member/banner/' + channel_code)
		.done(function(data) {
			dealFoundBanner(data);
		})
		.fail(function() {
			console.log('found banner error');
		});
	//	$.ajax({
	//		type: 'get',
	//		url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/banner/34998a46-7aca-46b9-b3aa-17ec7dac5275',
	//		json: true,
	//		contentType: 'application/json',
	//		success: function(data) {
	//			console.log(data);
	//			dealFoundBanner(data);
	//		},
	//		error: function(data) {
	//			console.log('home banner error,data:' + data);
	//		}
	//	});

	function dealFoundBanner(json) {
		for(var found_banner_num = 0; found_banner_num < json.items.length; found_banner_num++) {
			var found_banner_container = document.getElementsByClassName('swiper-container-found');
			var div = document.createElement('div');
			div.className = 'swiper-slide';
			var a = document.createElement('a');
			a.href = json.items[found_banner_num].jump_url;
			var img = document.createElement('img');
			img.src = json.items[found_banner_num].cover;
			a.appendChild(img);
			div.appendChild(a);
			found_banner_container[0].children[0].appendChild(div);
		}
	}

	//获取首页热门排行数据
	//	$.ajax({
	//		type: 'get',
	//		//临时url
	//		url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/game',
	//		/*
	//		 * 参数
	//		?page=1&per_page=5
	//		page: [可选]默认值 1 是首页；传 0 表示最后一页
	//		per_page: [可选]默认值 5 每页有五条记录
	//		category: [可选] 分类
	//		name:[可选] 游戏名称
	//		*/
	//		data: JSON.stringify({
	//			//						"avatar": "http://cdn.shidaiwl.cn/avator/avatar_102.png"
	//		}),
	//		json: true,
	//		contentType: 'application/json',
	//		success: function(data) {
	//			if(isNull(data) == '') {
	//				alert('获取首页热门排行数据出错，请稍候再试~~');
	//				return;
	//			}
	//			console.log('home 热门排行  success,data:' + data);
	//			dealHomeHotList(data);
	//		},
	//		error: function(data) {
	//			console.log('home 热门排行  error,data:' + data);
	//		}
	//	});

	//获取首页热门排行数据
	//	?page=1&per_page=5
	//	page: [可选]默认值 1 是首页；传 0 表示最后一页
	//	per_page: [可选]默认值 5 每页有五条记录
	//	tag: [可选] 标签   热门:0x0008 ，推荐:0x0010，精品:0x0020，最近更新:0x0040，新游预约:0x0080，每日发现:0x0100
	console.log('sadfjfsdl');
	request(base_url + '/game/member/game/channel/' + channel_code, {
			"type": "map",
			"content": {
				"area_tag": "8",
				"page": "1",
				"per_page": "10"
			}
		})
		.done(function(data) {
			dealHomeHotList(data);
		})
		.fail(function() {
			console.log('dealHomeHotList error');
		});

	function dealHomeHotList(json) {
		if(json.count == 0) {
			var home_column_title_main = document.getElementById('home_column_title_main');
			home_column_title_main.style.visibility = "hidden";
			return;
		}

		var home_hotgame_container = document.getElementsByClassName('swiper-container-column-home');

		for(var home_hotgame_num = 0; home_hotgame_num < json.items.length; home_hotgame_num++) {

			/*外围span*/
			var span = document.createElement('span');
			span.className = 'swiper-slide';
			span.style.textAlign = 'center';
			span.setAttribute('data_android_link', json.items[home_hotgame_num].android_link); //安卓下载链接
			span.setAttribute('data_ios_link', json.items[home_hotgame_num].ios_link); //IOS下载链接
			/*a标签*/
			var a = document.createElement('a');
			a.id = json.items[home_hotgame_num].id;
			a.href = 'detail.html';
			var span1 = document.createElement('span');
			span1.className = 'mui-icon';
			var img = document.createElement('img');
			img.src = json.items[home_hotgame_num].icon; //小图icon
			span1.appendChild(img);
			var h3 = document.createElement('h3');
			h3.className = 'home_column_title';
			h3.innerText = json.items[home_hotgame_num].game_name; //游戏名字
			a.appendChild(span1);
			a.appendChild(h3);
			span.appendChild(a);

			/*星星*/
//			var h4 = document.createElement('h4');
//			h4.className = 'mui-media-body';
//
//			var tem = '';
//			var score_avg = json.items[home_hotgame_num].score_avg; //几个星
//
//			var score_avg_x10 = score_avg * 10;
//			var score_avg_x10_ = score_avg_x10 % 10;
//			if(score_avg_x10_ > 0 && score_avg_x10_ <= 5) {
//				needHalfStar = true;
//			} else {
//				needHalfStar = false;
//			}
//			//							alert(needHalfStar);
//			for(var home_hotgame_starnum = 0; home_hotgame_starnum < 5; home_hotgame_starnum++) {
//				if(home_hotgame_starnum < parseInt(score_avg)) {
//					tem += '<span class="iconfont icon-xing1"></span>';
//				} else {
//					if(home_hotgame_starnum == parseInt(score_avg) && needHalfStar) {
//						tem += '<span class="iconfont icon-ban_xing2"></span>';
//					} else {
//						if(home_hotgame_starnum == parseInt(score_avg) && score_avg_x10_ > 5) {
//							tem += '<span class="iconfont icon-xing1"></span>';
//						} else {
//							tem += '<span class="iconfont icon-xingxing"></span>';
//						}
//					}
//				}
//			}
//			h4.innerHTML = tem;
//			span.appendChild(h4);

			/*下载按钮*/
			var h3_download = document.createElement('h3');
			h3_download.className = 'mui-media-body home_download';
			var span2 = document.createElement('span');
			span2.className = 'home_download_child iconfont icon-xiazai';
			span2.innerText = '下载';
			h3_download.appendChild(span2);
			span.appendChild(h3_download);

			home_hotgame_container[0].children[0].appendChild(span);
		}
		mui('.swiper-container-column-home').on('tap', 'a', function() {
			//跳转到详情
			//						alert('dealHomeHotList--'+this.id);
			window.name = this.id;
			window.location.href = 'detail.html';
		})
		mui('.swiper-container-column-home').on('tap', '.home_download_child', function() {
			var spanObj = this.parentNode;
			while(spanObj.nodeName != 'SPAN' && spanObj.parentNode != null) {
				spanObj = spanObj.parentNode;
			}
			download(isIOSClient(), spanObj.getAttribute('data_ios_link'), spanObj.getAttribute('data_android_link'));
		})

		//首页column的swiper
		new Swiper('.swiper-container-column-home', {
			direction: 'horizontal', //'horizontal',//'vertical',
			loop: false,
			slidesPerView: 4.3,
			paginationClickable: true,
			observer: true, //修改swiper自己或子元素时，自动初始化swiper
			observeParents: true, //修改swiper的父元素时，自动初始化swiper
			// 如果需要分页器
			//pagination: '.swiper-pagination',
		})
	}

	//获取首页游戏推荐数据
	//	$.ajax({
	//		type: 'get',
	//		//					url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/banner/34998a46-7aca-46b9-b3aa-17ec7dac5275',
	//		//临时url
	//		url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/game',
	//		json: true,
	//		contentType: 'application/json',
	//		/*
	//		 * 参数
	//		?page=1&per_page=5
	//		page: [可选]默认值 1 是首页；传 0 表示最后一页
	//		per_page: [可选]默认值 5 每页有五条记录
	//		category: [可选] 分类
	//		name:[可选] 游戏名称
	//		*/
	//		data: JSON.stringify({
	//			//						"avatar": "http://cdn.shidaiwl.cn/avator/avatar_102.png"
	//		}),
	//		success: function(data) {
	//			if(isNull(data) == '') {
	//				alert('获取首页游戏推荐数据出错，请稍候再试~~');
	//				return;
	//			}
	//			console.log('home 游戏推荐  success,data:' + data);
	//			dealHomeRecommendList(data);
	//		},
	//		error: function(data) {
	//			console.log('home 游戏推荐  error,data:' + data);
	//		}
	//	});

	//获取首页游戏推荐数据
	//	?page=1&per_page=5
	//	page: [可选]默认值 1 是首页；传 0 表示最后一页
	//	per_page: [可选]默认值 5 每页有五条记录
	//	tag: [可选] 标签   热门:0x0008 ，推荐:0x0010，精品:0x0020，最近更新:0x0040，新游预约:0x0080，每日发现:0x0100

	request(base_url + '/game/member/game/channel/' + channel_code, {
			"type": "map",
			"content": {
				"area_tag": "16",
				"page": "1",
				"per_page": "10"
			}
		})
		.done(function(data) {
			dealHomeRecommendList(data);
		})
		.fail(function() {
			console.log('dealHomeRecommendList error');
		});

	function dealHomeRecommendList(json) {
		if(json.count == "0") {
			var home_bigitem_title_main = document.getElementById('home_bigitem_title_main');
			home_bigitem_title_main.style.visibility = "hidden";
			return;
		}

		var home_bigitem_container = document.getElementsByClassName('home_bigitem_list');

		for(var home_recommendgame_num = 0; home_recommendgame_num < json.items.length; home_recommendgame_num++) {
			/*整个div*/
			var div_all = document.createElement('div');
			div_all.className = 'mui-row';
			div_all.id = json.items[home_recommendgame_num].id;

			/*左边div*/
			var div_left = document.createElement('div');
			div_left.className = 'mui-col-sm-6 mui-col-xs-6';
			var img = document.createElement('img');
			img.className = 'big_item_img';
			img.id = json.items[home_recommendgame_num].id;
			img.src = json.items[home_recommendgame_num].front_cover; //bigitem大图
			div_left.appendChild(img);

			/*右边div*/
			var div_right = document.createElement('div');
			div_right.className = 'mui-col-sm-6 mui-col-xs-6';
			var div_right_html = '<div id="' +
				json.items[home_recommendgame_num].id + //id
				'" class="mui-ellipsis big_item_column_title">' +
				json.items[home_recommendgame_num].game_name + //bigitem主标题
				'-<span class="big_item_column_title_tail">' +
				json.items[home_recommendgame_num].game_title + //bigitem副标题
				'</span></div><div id="' +
				json.items[home_recommendgame_num].id + //id
				'" class="mui-row big_item_column_text"><div class="mui-col-sm-8 mui-col-xs-8 mui-ellipsis-4" style="position: absolute;bottom: 0;">' +
				json.items[home_recommendgame_num].description + //描述
				'</div><div class="div_bigitem_download"><div class="big_item_download iconfont icon-xiazai" data_android_link="' +
				json.items[home_recommendgame_num].android_link + //安卓链接
				'" data_ios_link ="' +
				json.items[home_recommendgame_num].ios_link + //IOS链接
				'">下载</div></div>';
			div_right.innerHTML = div_right_html;

			/*下滑线*/
			var div_cutdown = document.createElement('div');
			div_cutdown.className = 'home_bigitem_cut_off_line';

			div_all.appendChild(div_left);
			div_all.appendChild(div_right);
			home_bigitem_container[0].appendChild(div_all);
			home_bigitem_container[0].appendChild(div_cutdown);
		}
		mui('.home_bigitem_list').on('tap', '.big_item_img', function() {
			//跳转到详情
			//						alert('home_bigitem_list--'+this.id);
			window.name = this.id;
			window.location.href = 'detail.html';
			return false;
		})
		mui('div').on('tap', '.big_item_column_title', function() {
			//跳转到详情
			window.name = this.id;
			window.location.href = 'detail.html';
			return false;
		})
		mui('div').on('tap', '.big_item_column_text', function() {
			//跳转到详情
			window.name = this.id;
			window.location.href = 'detail.html';
			return false;
		})
		mui('.div_bigitem_download').on('tap', '.big_item_download', function() {
			download(isIOSClient(), this.getAttribute('data_ios_link'), this.getAttribute('data_android_link'));
			return false;
		})

	}

	//获取首页精品游戏数据
	//	$.ajax({
	//		type: 'get',
	//		//					url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/banner/34998a46-7aca-46b9-b3aa-17ec7dac5275',
	//		//临时url
	//		url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/game',
	//		json: true,
	//		/*
	//		 * 参数
	//		?page=1&per_page=5
	//		page: [可选]默认值 1 是首页；传 0 表示最后一页
	//		per_page: [可选]默认值 5 每页有五条记录
	//		category: [可选] 分类
	//		name:[可选] 游戏名称
	//		*/
	//		data: JSON.stringify({
	//			//						"avatar": "http://cdn.shidaiwl.cn/avator/avatar_102.png"
	//		}),
	//		contentType: 'application/json',
	//		success: function(data) {
	//			if(isNull(data) == '') {
	//				alert('获取首页精品游戏数据出错，请稍候再试~~');
	//				return;
	//			}
	//			console.log('home 精品游戏  success,data:' + data);
	//			dealHomeJingPinList(data);
	//		},
	//		error: function(data) {
	//			console.log('home 精品游戏  error,data:' + data);
	//		}
	//	});

	//	获取首页精品游戏数据
	//	?page=1&per_page=5
	//	page: [可选]默认值 1 是首页；传 0 表示最后一页
	//	per_page: [可选]默认值 5 每页有五条记录
	//	tag: [可选] 标签   热门:0x0008 ，推荐:0x0010，精品:0x0020，最近更新:0x0040，新游预约:0x0080，每日发现:0x0100

	request(base_url + '/game/member/game/channel/' + channel_code, {
			"type": "map",
			"content": {
				"area_tag": "32",
				"page": "1",
				"per_page": "10"
			}
		})
		.done(function(data) {
			dealHomeJingPinList(data);
		})
		.fail(function() {
			console.log('dealHomeJingPinList error');
		});

	function dealHomeJingPinList(json) {
		if(json.count == "0") {
			var home_jingpin_title_main = document.getElementById('home_jingpin_title_main');
			home_jingpin_title_main.style.visibility = "hidden";
			return;
		}

		var home_jingpin_container = document.getElementsByClassName('home_jingpin_list');

		for(var home_jingpingame_num = 0; home_jingpingame_num < json.items.length; home_jingpingame_num++) {
			/*整个div*/
			var div_all = document.createElement('div');
			div_all.className = 'mui-row jingpin';

			/*左边div*/
			var div_left = document.createElement('div');
			div_left.className = 'mui-col-sm-2 mui-col-xs-2';
			var img = document.createElement('img');

			img.className = 'jingpin_item_img';
			img.src = json.items[home_jingpingame_num].icon; //图片icon
			img.id = json.items[home_jingpingame_num].id;
			div_left.appendChild(img);

			/*右边div*/
			var div_middle = document.createElement('div');
			div_middle.className = 'mui-col-sm-8 mui-col-xs-8';
			var div_middle_html = '<div id=' +
				json.items[home_jingpingame_num].id + //id
				' class="jingpin_text" style=" position:relative;"><div class="jingpin_text_one">' +
				json.items[home_jingpingame_num].game_name + //主标题
				'-<span class="big_item_column_title_tail">' +
				json.items[home_jingpingame_num].game_title + //副标题
				'</span></div><div class="mui-ellipsis-2 jingpin_text_two">' +
				json.items[home_jingpingame_num].description + //描述
				'</div></div>';
			div_middle.innerHTML = div_middle_html;

			/*右边div*/
			var div_right = document.createElement('div');
			div_right.className = 'mui-col-sm-2 mui-col-xs-2';
			var div_right_html = '<div class="mui-pull-right jingpin_download iconfont icon-xiazai" data_android_link="' +
				json.items[home_jingpingame_num].android_link + //安卓链接
				'" data_ios_link ="' +
				json.items[home_jingpingame_num].ios_link + //IOS链接
				'">下载</div>';
			div_right.innerHTML = div_right_html;

			/*下滑线*/
			var div_cutdown = document.createElement('div');
			div_cutdown.className = 'home_bigitem_cut_off_line';

			div_all.appendChild(div_left);
			div_all.appendChild(div_middle);
			div_all.appendChild(div_right);
			home_jingpin_container[0].appendChild(div_all);
			home_jingpin_container[0].appendChild(div_cutdown);

		}
		mui('.home_jingpin_list').on('tap', '.jingpin_item_img', function() {
			//跳转到详情
			window.name = this.id;
			window.location.href = 'detail.html';
			return false;
		})
		mui('.home_jingpin_list').on('tap', '.jingpin_text', function() {
			//跳转到详情
			window.name = this.id;
			window.location.href = 'detail.html';
			return false;
		})
		mui('.home_jingpin_list').on('tap', '.jingpin_download', function() {
			download(isIOSClient(), this.getAttribute('data_ios_link'), this.getAttribute('data_android_link'));
			return false;
		})
	}

	//获取发现页每日新发现数据
	//	$.ajax({
	//		type: 'get',
	//		//					url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/banner/34998a46-7aca-46b9-b3aa-17ec7dac5275',
	//		//临时url
	//		url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/game',
	//		json: true,
	//		contentType: 'application/json',
	//		/*
	//		 * 参数
	//		?page=1&per_page=5
	//		page: [可选]默认值 1 是首页；传 0 表示最后一页
	//		per_page: [可选]默认值 5 每页有五条记录
	//		category: [可选] 分类
	//		name:[可选] 游戏名称
	//		*/
	//		data: JSON.stringify({
	//			//						"avatar": "http://cdn.shidaiwl.cn/avator/avatar_102.png"
	//		}),
	//		success: function(data) {
	//			if(isNull(data) == '') {
	//				alert('获取每日新发现数据出错，请稍候再试~~');
	//				return;
	//			}
	//			console.log('每日新发现  success,data:' + data);
	//			dealFoundEveryDayList(data);
	//		},
	//		error: function(data) {
	//			console.log('每日新发现  error,data:' + data);
	//		}
	//	});

	//	获取发现页每日新发现数据
	//	?page=1&per_page=5
	//	page: [可选]默认值 1 是首页；传 0 表示最后一页
	//	per_page: [可选]默认值 5 每页有五条记录
	//	tag: [可选] 标签   热门:0x0008 ，推荐:0x0010，精品:0x0020，最近更新:0x0040，新游预约:0x0080，每日发现:0x0100

	request(base_url + '/game/member/game/channel/' + channel_code, {
			"type": "map",
			"content": {
				"area_tag": "256",
				"page": "1",
				"per_page": "10"
			}
		})
		.done(function(data) {
			dealFoundEveryDayList(data);
		})
		.fail(function() {
			console.log('dealFoundEveryDayList error');
		});

	function dealFoundEveryDayList(json) {
		if(json.count == 0) {
			var found_everydayfound = document.getElementById('found_everydayfound');
			found_everydayfound.style.visibility = "hidden";
			return;
		}

		var found_everyday_container = document.getElementById('everydayfound');

		for(var found_everyday_num = 0; found_everyday_num < json.items.length; found_everyday_num++) {
			/*整个div*/
			var span = document.createElement('span');
			span.className = 'swiper-slide';

			var tmpHtml = '<a id="' +
				json.items[found_everyday_num].id + //跳转页面
				'"><img src="' +
				json.items[found_everyday_num].icon + //图片icon
				'"/><h3 class="everydayfound_column_title">' +
				json.items[found_everyday_num].game_name + //主标题 
				'</h3></a><h3 class="everydayfound_download iconfont icon-xiazai" data_android_link="' +
				json.items[found_everyday_num].android_link + //安卓链接
				'" data_ios_link ="' +
				json.items[found_everyday_num].ios_link + //IOS链接
				'">下载</div></div>';
			span.innerHTML = tmpHtml;
			found_everyday_container.appendChild(span);
		}

		mui('#everydayfound').on('tap', '.everydayfound_download', function() {
			//						alert('everydayfound--'+this.getAttribute('data_android_link'));
			download(isIOSClient(), this.getAttribute('data_ios_link'), this.getAttribute('data_android_link'));
		})

	}

	//获取发现页新游预约数据
	//	$.ajax({
	//		type: 'get',
	//		//					url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/banner/34998a46-7aca-46b9-b3aa-17ec7dac5275',
	//		//临时url
	//		url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/game',
	//		json: true,
	//		contentType: 'application/json',
	//		/*
	//		 * 参数
	//		?page=1&per_page=5
	//		page: [可选]默认值 1 是首页；传 0 表示最后一页
	//		per_page: [可选]默认值 5 每页有五条记录
	//		category: [可选] 分类
	//		name:[可选] 游戏名称
	//		*/
	//		data: JSON.stringify({
	//			//						"avatar": "http://cdn.shidaiwl.cn/avator/avatar_102.png"
	//		}),
	//		success: function(data) {
	//			if(isNull(data) == '') {
	//				alert('获取新游预约数据出错，请稍候再试~~');
	//				return;
	//			}
	//			console.log('新游预约  success,data:' + data);
	//			dealFoundNewGameList(data);
	//		},
	//		error: function(data) {
	//			console.log('新游预约  error,data:' + data);
	//		}
	//	});

	//	获取发现页新游预约数据
	//	?page=1&per_page=5
	//	page: [可选]默认值 1 是首页；传 0 表示最后一页
	//	per_page: [可选]默认值 5 每页有五条记录
	//	tag: [可选] 标签   热门:0x0008 ，推荐:0x0010，精品:0x0020，最近更新:0x0040，新游预约:0x0080，每日发现:0x0100

	request(base_url + '/game/member/game/channel/' + channel_code, {
			"type": "map",
			"content": {
				"area_tag": "128",
				"page": "1",
				"per_page": "10"
			}
		})
		.done(function(data) {
			dealFoundNewGameList(data);
		})
		.fail(function() {
			console.log('dealFoundNewGameList error');
		});

	function dealFoundNewGameList(json) {
		if(json.count == 0) {
			var found_newgameorder = document.getElementById('found_newgameorder');
			found_newgameorder.style.visibility = "hidden";

			var found_newgameorder_line = document.getElementById('found_newgameorder_line');
			found_newgameorder_line.style.visibility = "hidden";

			return;
		}

		var found_newgame_container = document.getElementById('newgameorder');

		for(var found_newgameorder_num = 0; found_newgameorder_num < json.items.length; found_newgameorder_num++) {
			/*整个div*/
			var span = document.createElement('span');
			span.className = 'swiper-slide';

			var tmpHtml = '<a id="' +
				json.items[found_newgameorder_num].id + //跳转页面
				'"><img src="' +
				json.items[found_newgameorder_num].icon + //图片icon
				'"/><h3 class="newgameorder_column_title">' +
				json.items[found_newgameorder_num].game_name + //主标题 
				'</h3></a><h3 class="newgameorder_download iconfont icon-xiazai" data_android_link="' +
				json.items[found_newgameorder_num].android_link + //安卓链接
				'" data_ios_link ="' +
				json.items[found_newgameorder_num].ios_link + //IOS链接
				'">下载</h3>';
			span.innerHTML = tmpHtml;
			found_newgame_container.appendChild(span);
		}
		mui('#newgameorder').on('tap', '.newgameorder_download', function() {
			//						alert(this.getAttribute('data_android_link'));
			download(isIOSClient(), this.getAttribute('data_ios_link'), this.getAttribute('data_android_link'));
		})
	}

	//获取发现页最近更新数据
	//	$.ajax({
	//		type: 'get',
	//		//					url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/banner/34998a46-7aca-46b9-b3aa-17ec7dac5275',
	//		//临时url
	//		url: 'http://api.staging.shidaiwl.cn/api/v1/game/member/game',
	//		json: true,
	//		contentType: 'application/json',
	//		/*
	//		 * 参数
	//		?page=1&per_page=5
	//		page: [可选]默认值 1 是首页；传 0 表示最后一页
	//		per_page: [可选]默认值 5 每页有五条记录
	//		category: [可选] 分类
	//		name:[可选] 游戏名称
	//		*/
	//		data: JSON.stringify({
	//			//						"avatar": "http://cdn.shidaiwl.cn/avator/avatar_102.png"
	//		}),
	//		success: function(data) {
	//			if(isNull(data) == '') {
	//				alert('发现页最近更新数据出错，请稍候再试~~');
	//				return;
	//			}
	//			console.log('发现页最近更新  success,data:' + data);
	//			dealFoundLastestUpdateList(data);
	//		},
	//		error: function(data) {
	//			console.log('发现页最近更新  error,data:' + data);
	//		}
	//	});

	//	获取发现页新游预约数据
	//	?page=1&per_page=5
	//	page: [可选]默认值 1 是首页；传 0 表示最后一页
	//	per_page: [可选]默认值 5 每页有五条记录
	//	tag: [可选] 标签   热门:0x0008 ，推荐:0x0010，精品:0x0020，最近更新:0x0040，新游预约:0x0080，每日发现:0x0100

	request(base_url + '/game/member/game/channel/' + channel_code, {
			"type": "map",
			"content": {
				"area_tag": "64",
				"page": "1",
				"per_page": "10"
			}
		})
		.done(function(data) {
			dealFoundLastestUpdateList(data);
		})
		.fail(function() {
			console.log('dealFoundLastestUpdateList error');
		});

	function dealFoundLastestUpdateList(json) {
		if(json.count == 0) {
			var found_lastestupdate = document.getElementById('found_lastestupdate');
			found_lastestupdate.style.visibility = "hidden";

			var found_lastestupdate_line = document.getElementById('found_lastestupdate_line');
			found_lastestupdate_line.style.visibility = "hidden";
			return;
		}

		var found_lastestupdate_container = document.getElementById('lastestupdate');

		for(var found_lastestupdate_num = 0; found_lastestupdate_num < json.items.length; found_lastestupdate_num++) {
			/*整个div*/
			var span = document.createElement('span');
			span.className = 'swiper-slide';

			var tmpHtml = '<a id="' +
				json.items[found_lastestupdate_num].id + //跳转页面
				'"><img src="' +
				json.items[found_lastestupdate_num].icon + //图片icon
				'"/><h3 class="lastestupdate_column_title">' +
				json.items[found_lastestupdate_num].game_name + //主标题 
				'</h3></a><h3 class="lastestupdate_download iconfont icon-xiazai" data_android_link="' +
				json.items[found_lastestupdate_num].android_link + //安卓链接
				'" data_ios_link ="' +
				json.items[found_lastestupdate_num].ios_link + //IOS链接
				'">下载</h3>';
			span.innerHTML = tmpHtml;
			found_lastestupdate_container.appendChild(span);
		}
		mui('#lastestupdate').on('tap', '.lastestupdate_download', function() {
			//						alert(this.getAttribute('data_android_link'));
			download(isIOSClient(), this.getAttribute('data_ios_link'), this.getAttribute('data_android_link'));
		})
	}

	//发现页图标点击
	mui('.swiper-container-column-found').on('tap', 'a', function() {
		//跳转到详情
		window.name = this.id;
		window.location.href = 'detail.html';
		return false;
	})

	//发现页点击查看更多
	mui('div').on('tap', '.found_column_title_more', function() {
		window.location = 'allgame.html';
		return false;
	});
	//首页banner的swiper
	var home_banner = new Swiper('.swiper-container-home', {
		direction: 'horizontal', //'horizontal',//'vertical',
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //修改swiper的父元素时，自动初始化swiper
		// 如果需要分页器
		pagination: '.swiper-pagination',
		autoplay: 4500,
		autoplayDisableOnInteraction: false, //注意此参数，默认为true
	})

	//发现页banner的swiper
	var found_banner = new Swiper('.swiper-container-found', {
		direction: 'horizontal', //'horizontal',//'vertical',
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //修改swiper的父元素时，自动初始化swiper
		// 如果需要分页器
		pagination: '.swiper-pagination',
		autoplay: 4500,
		autoplayDisableOnInteraction: false, //注意此参数，默认为true
	})

	//发现页column的swiper
	new Swiper('.swiper-container-column-found', {
		direction: 'horizontal', //'horizontal',//'vertical',
		loop: false,
		slidesPerView: 4.3,
		paginationClickable: true,
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //修改swiper的父元素时，自动初始化swiper
		// 如果需要分页器
		//pagination: '.swiper-pagination',
	})


	init_xiaoluwu_click();
	//初始化福利页面点击
	function init_xiaoluwu_click() {
		mui('div').on('tap', '.btn_xiaoliwu', function() {
			var body = document.getElementsByTagName('body');
			var temdiv = document.createElement('div');
			temdiv.innerHTML = '<div id="a" class="mui-popup mui-popup-in" style="display: block;;"><div class="mui-popup-inner"><div class="mui-popup-title"></div><div class="mui-popup-text" style="font-size: 0.26rem;color: #333333;">恭喜你获得下载福利礼包<div style="color:#FF6494;padding-top: 0.2rem;">SHD24894AJS</div></div></div><div class="mui-popup-buttons" style="background-color: rgba(255,255,255,0.95)"><span class="mui-popup-button" style="color: white;">复制兑换码</span></div></div><div id="b" class="mui-popup-backdrop mui-active" style="display: block;"></div>';
			body[0].appendChild(temdiv);
			var clicktarget = this;
			mui('div').on('tap', '.mui-popup-buttons', function() {
				var a = document.getElementById('a');
				var b = document.getElementById('b');
				a.remove();
				b.remove();
				clicktarget.innerText = 'SHD24894AJS';
				clicktarget.style.backgroundColor = '#e9e9e9';
				clicktarget.enabled = 'false';
			});
			return false;
		});
	}

	var home_close = document.getElementById('home_close');
	home_close.addEventListener('tap',function(){
		alert("关闭");
	})
	var found_close = document.getElementById('found_close');
	found_close.addEventListener('tap',function(){
		alert("关闭");
	})

	mui('body').on('tap', 'a', function() {
		document.location.href = this.href;
	});
}